#include <iostream>
#include <vector>

using std::cout;
using std::endl;
using std::vector;

vector<int> pickVec;

bool find(int val)
{
    for(int v: pickVec){
        if(val == v)
            return true;
    }
    return false;
}

void fun(int *arr, int i, int len)
{
    if(i == len){
        for(int v: pickVec){
            cout << v << " ";
        }
        cout << endl;
    }else{
        for(int j{}; j < len; j++){
            if(!find(arr[j])){
                pickVec.push_back(arr[j]);
                fun(arr, i + 1, len);
                pickVec.pop_back();
            }
        }
    }
}

int main(int args, char *argv[])
{
    int arr[] = {1, 2, 3};
    int len = sizeof(arr) / sizeof(int);
    
    fun(arr, 0, len);    

    return 0;
}